package cn.service.marketingService.MarketingServiceImpl;

import cn.service.marketingService.SeckillTimeService;
import entity.Result;
import entity.marketingEntity.SeckillTime;
import mapper.marketingMapper.SeckillTimeMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 朱颢阳
 * @description
 * @time 2024/8/31 14:00
 */
@Service
public class SeckillTimeServiceImpl implements SeckillTimeService {
    @Resource
    SeckillTimeMapper mapper;

    @Override
    public Result gettimes() {
        return Result.success(200,mapper.selectByPrimaryKey());
    }

    @Override
    public Result updatetimesstate(Integer id, Integer state) {
        if (mapper.updatetimesstate(id,state)>0){
            return Result.success("启用状态更新成功");
        }else{
            return  Result.failed(500,"启用状态更新失败");
        }
    }

    @Override
    public Result addtimes(SeckillTime seckillTime) {
        if (mapper.insertSelective(seckillTime)>0){
            return Result.success("添加成功");
        }else{
            return  Result.failed(500,"添加失败");
        }
    }

    @Override
    public Result modifytimes(SeckillTime seckillTime) {
        if (mapper.updateByPrimaryKeySelective(seckillTime)>0){
            return Result.success("修改成功");
        }else{
            return  Result.failed(500,"修改失败");
        }
    }

    @Override
    public Result deletetimes(Integer id) {
        if (mapper.deleteByPrimaryKey(id)>0){
            return Result.success("删除成功");
        }else{
            return  Result.failed(500,"删除失败");
        }
    }

    @Override
    public Result getflashlist(Integer id) {
        return Result.success(200,mapper.getflashlist(id));
    }
}
